package com.cch.cooperation.api.feedback.controller;

import com.cch.cooperation.api.auth.dto.LoginUserDTO;
import com.cch.cooperation.api.feedback.dto.FeedbackAddDTO;
import com.cch.cooperation.api.feedback.service.FeedbackServiceImpl;
import com.cch.cooperation.common.web.response.Response;
import com.cch.cooperation.common.web.session.Session;
import com.cch.cooperation.common.web.session.SessionManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 反馈接口
 *
 * @author cch
 */
@Api(tags = "反馈接口")
@RestController
@RequestMapping("/api/feedback")
public class FeedbackController {

    @Resource
    private FeedbackServiceImpl feedbackService;
    @Resource
    private SessionManager sessionManager;

    @ApiOperation("新增反馈")
    @PostMapping("/add")
    public Response<Void> add(@RequestBody FeedbackAddDTO req) {
        Session<LoginUserDTO> session = sessionManager.get();
        req.setUserId(session.getData().getId());
        feedbackService.add(req);
        return Response.success();
    }
}
